Imports cmplib01

Public Class frmEditMovementValues
    Inherits System.Windows.Forms.Form

    Private ptrUnit As UnitType

    Private m_Cancelled As Boolean
    Private MoveTypeNames(10) As String

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents btnCancel As System.Windows.Forms.Button
    Friend WithEvents btnOK As System.Windows.Forms.Button
    Friend WithEvents pnlTopBorder As System.Windows.Forms.Panel
    Friend WithEvents picCampaignerIcon As System.Windows.Forms.PictureBox
    Friend WithEvents txtTitleBox As System.Windows.Forms.TextBox
    Friend WithEvents pnlAPanel As System.Windows.Forms.Panel
    Friend WithEvents lblFactionOnePoints As System.Windows.Forms.Label
    Friend WithEvents lblMovementSpeed As System.Windows.Forms.Label
    Friend WithEvents cboMovementTypes As System.Windows.Forms.ComboBox
    Friend WithEvents txtMovementSpeed As System.Windows.Forms.TextBox
    Friend WithEvents lblMPH As System.Windows.Forms.Label
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(frmEditMovementValues))
        Me.pnlAPanel = New System.Windows.Forms.Panel
        Me.lblMPH = New System.Windows.Forms.Label
        Me.txtMovementSpeed = New System.Windows.Forms.TextBox
        Me.lblMovementSpeed = New System.Windows.Forms.Label
        Me.lblFactionOnePoints = New System.Windows.Forms.Label
        Me.cboMovementTypes = New System.Windows.Forms.ComboBox
        Me.btnCancel = New System.Windows.Forms.Button
        Me.btnOK = New System.Windows.Forms.Button
        Me.pnlTopBorder = New System.Windows.Forms.Panel
        Me.picCampaignerIcon = New System.Windows.Forms.PictureBox
        Me.txtTitleBox = New System.Windows.Forms.TextBox
        Me.pnlAPanel.SuspendLayout()
        Me.pnlTopBorder.SuspendLayout()
        CType(Me.picCampaignerIcon, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.SuspendLayout()
        '
        'pnlAPanel
        '
        Me.pnlAPanel.BackColor = System.Drawing.Color.LightSkyBlue
        Me.pnlAPanel.Controls.Add(Me.lblMPH)
        Me.pnlAPanel.Controls.Add(Me.txtMovementSpeed)
        Me.pnlAPanel.Controls.Add(Me.lblMovementSpeed)
        Me.pnlAPanel.Controls.Add(Me.lblFactionOnePoints)
        Me.pnlAPanel.Controls.Add(Me.cboMovementTypes)
        Me.pnlAPanel.Location = New System.Drawing.Point(8, 56)
        Me.pnlAPanel.Name = "pnlAPanel"
        Me.pnlAPanel.Size = New System.Drawing.Size(272, 88)
        Me.pnlAPanel.TabIndex = 24
        '
        'lblMPH
        '
        Me.lblMPH.Location = New System.Drawing.Point(200, 16)
        Me.lblMPH.Name = "lblMPH"
        Me.lblMPH.Size = New System.Drawing.Size(56, 24)
        Me.lblMPH.TabIndex = 9
        Me.lblMPH.Text = "MPH"
        '
        'txtMovementSpeed
        '
        Me.txtMovementSpeed.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.txtMovementSpeed.Location = New System.Drawing.Point(112, 16)
        Me.txtMovementSpeed.Name = "txtMovementSpeed"
        Me.txtMovementSpeed.Size = New System.Drawing.Size(80, 20)
        Me.txtMovementSpeed.TabIndex = 8
        Me.txtMovementSpeed.Text = "0"
        Me.txtMovementSpeed.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
        '
        'lblMovementSpeed
        '
        Me.lblMovementSpeed.Location = New System.Drawing.Point(16, 16)
        Me.lblMovementSpeed.Name = "lblMovementSpeed"
        Me.lblMovementSpeed.Size = New System.Drawing.Size(96, 24)
        Me.lblMovementSpeed.TabIndex = 7
        Me.lblMovementSpeed.Text = "Movement Speed"
        '
        'lblFactionOnePoints
        '
        Me.lblFactionOnePoints.Location = New System.Drawing.Point(16, 51)
        Me.lblFactionOnePoints.Name = "lblFactionOnePoints"
        Me.lblFactionOnePoints.Size = New System.Drawing.Size(96, 24)
        Me.lblFactionOnePoints.TabIndex = 5
        Me.lblFactionOnePoints.Text = "Movement Type"
        '
        'cboMovementTypes
        '
        Me.cboMovementTypes.Location = New System.Drawing.Point(112, 48)
        Me.cboMovementTypes.Name = "cboMovementTypes"
        Me.cboMovementTypes.Size = New System.Drawing.Size(120, 21)
        Me.cboMovementTypes.TabIndex = 0
        Me.cboMovementTypes.Text = "Infantry"
        '
        'btnCancel
        '
        Me.btnCancel.BackColor = System.Drawing.Color.LightSkyBlue
        Me.btnCancel.FlatStyle = System.Windows.Forms.FlatStyle.Flat
        Me.btnCancel.ForeColor = System.Drawing.Color.Black
        Me.btnCancel.Location = New System.Drawing.Point(192, 152)
        Me.btnCancel.Name = "btnCancel"
        Me.btnCancel.Size = New System.Drawing.Size(75, 23)
        Me.btnCancel.TabIndex = 23
        Me.btnCancel.Text = "Cancel"
        Me.btnCancel.UseVisualStyleBackColor = False
        '
        'btnOK
        '
        Me.btnOK.BackColor = System.Drawing.Color.LightSkyBlue
        Me.btnOK.FlatStyle = System.Windows.Forms.FlatStyle.Flat
        Me.btnOK.ForeColor = System.Drawing.Color.Black
        Me.btnOK.Location = New System.Drawing.Point(112, 152)
        Me.btnOK.Name = "btnOK"
        Me.btnOK.Size = New System.Drawing.Size(75, 23)
        Me.btnOK.TabIndex = 22
        Me.btnOK.Text = "OK"
        Me.btnOK.UseVisualStyleBackColor = False
        '
        'pnlTopBorder
        '
        Me.pnlTopBorder.BackColor = System.Drawing.Color.SteelBlue
        Me.pnlTopBorder.Controls.Add(Me.picCampaignerIcon)
        Me.pnlTopBorder.Controls.Add(Me.txtTitleBox)
        Me.pnlTopBorder.Location = New System.Drawing.Point(0, 8)
        Me.pnlTopBorder.Name = "pnlTopBorder"
        Me.pnlTopBorder.Size = New System.Drawing.Size(296, 40)
        Me.pnlTopBorder.TabIndex = 21
        '
        'picCampaignerIcon
        '
        Me.picCampaignerIcon.Image = CType(resources.GetObject("picCampaignerIcon.Image"), System.Drawing.Image)
        Me.picCampaignerIcon.Location = New System.Drawing.Point(9, 11)
        Me.picCampaignerIcon.Name = "picCampaignerIcon"
        Me.picCampaignerIcon.Size = New System.Drawing.Size(16, 16)
        Me.picCampaignerIcon.TabIndex = 9
        Me.picCampaignerIcon.TabStop = False
        '
        'txtTitleBox
        '
        Me.txtTitleBox.BackColor = System.Drawing.Color.SteelBlue
        Me.txtTitleBox.BorderStyle = System.Windows.Forms.BorderStyle.None
        Me.txtTitleBox.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.txtTitleBox.ForeColor = System.Drawing.Color.WhiteSmoke
        Me.txtTitleBox.Location = New System.Drawing.Point(32, 8)
        Me.txtTitleBox.Multiline = True
        Me.txtTitleBox.Name = "txtTitleBox"
        Me.txtTitleBox.ReadOnly = True
        Me.txtTitleBox.Size = New System.Drawing.Size(256, 26)
        Me.txtTitleBox.TabIndex = 8
        Me.txtTitleBox.Text = "Campaigner [Movement]"
        '
        'frmEditMovementValues
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.BackColor = System.Drawing.Color.Black
        Me.ClientSize = New System.Drawing.Size(288, 184)
        Me.Controls.Add(Me.pnlAPanel)
        Me.Controls.Add(Me.btnCancel)
        Me.Controls.Add(Me.btnOK)
        Me.Controls.Add(Me.pnlTopBorder)
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow
        Me.Name = "frmEditMovementValues"
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent
        Me.pnlAPanel.ResumeLayout(False)
        Me.pnlAPanel.PerformLayout()
        Me.pnlTopBorder.ResumeLayout(False)
        Me.pnlTopBorder.PerformLayout()
        CType(Me.picCampaignerIcon, System.ComponentModel.ISupportInitialize).EndInit()
        Me.ResumeLayout(False)

    End Sub

#End Region

    Public Sub New(ByRef unie As UnitType)
        Me.New()
        ptrUnit = unie

        Dim i As Integer

        MoveTypeNames(0) = "Infantry"
        MoveTypeNames(1) = "Mechanized"
        MoveTypeNames(2) = "Fast"
        MoveTypeNames(3) = "Mounted"
        MoveTypeNames(4) = "Skimmer"
        MoveTypeNames(5) = "Wheeled"
        MoveTypeNames(6) = "Tracked"
        MoveTypeNames(7) = "Heavy"
        MoveTypeNames(8) = "Mixed"
        MoveTypeNames(9) = "Riverine"
        MoveTypeNames(10) = "Sea"

        For i = 0 To UBound(MoveTypeNames, 1)
            cboMovementTypes.Items.Add(MoveTypeNames(i))
        Next

        cboMovementTypes.Text = MoveTypeNames(ptrUnit.MovementClassID)
        txtMovementSpeed.Text = ptrUnit.MovementSpeed

    End Sub

    Public ReadOnly Property Cancelled() As Boolean
        Get
            Return m_Cancelled
        End Get
    End Property

    Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click
        Try
            ptrUnit.MovementClassID = cboMovementTypes.SelectedIndex
            ptrUnit.MovementSpeed = txtMovementSpeed.Text
        Catch ex As Exception
            MessageBox.Show("Movement Speed must be a numeric value.", "Invalid Value", MessageBoxButtons.OK)
        Finally
            m_Cancelled = False
            Me.Hide()
        End Try

    End Sub

    Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
        ' don't change anything
        m_Cancelled = True
        Me.Hide()
    End Sub
End Class
